package com.nbcio.pm.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.nbcio.common.tenant.core.TenantEntity;
import com.nbcio.pm.domain.vo.PmTimeTrackingVo;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 时间跟踪对象 pm_time_tracking
 *
 * @author nbacheng
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("pm_time_tracking")
@AutoMapper(target = PmTimeTrackingVo.class, reverseConvertGenerate = false)
public class PmTimeTracking extends TenantEntity {

    /**
     * ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 项目ID
     */
    @TableField("project_id")
    private Long projectId;

    /**
     * 任务ID
     */
    @TableField("task_id")
    private Long taskId;

    /**
     * 用户ID（单个用户）
     */
    @TableField("user_id")
    private Long userId;

    /**
     * 开始时间
     */
    @TableField("start_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;

    /**
     * 结束时间
     */
    @TableField("end_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;

    /**
     * 持续时间（小时）
     */
    @TableField("duration")
    private BigDecimal duration;

    /**
     * 工作描述
     */
    @TableField("description")
    private String description;

    /**
     * 是否可计费
     */
    @TableField("is_billable")
    private Boolean isBillable;

    /**
     * 小时费率
     */
    @TableField("hourly_rate")
    private BigDecimal hourlyRate;

    // 关联字段（非数据库字段）
    @TableField(exist = false)
    private String projectName;

    @TableField(exist = false)
    private String taskName;

    @TableField(exist = false)
    private String userName;
}
